﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Kelper.ViewModels
{
    public class MenuViewModel
    {
        public List<string> Controllers { get; private set; }
        public List<string> Actions { get; private set; }
        public List<string> Texts { get; private set; }
        public List<bool> Authenticated { get; private set; }
        public List<bool> NotAuthenticated { get; private set; }

        private ViewContext viewContext;

        public MenuViewModel(ViewContext viewContext)
        {
            this.viewContext = viewContext;

            Controllers = new List<string> { "Home", "Category", "Search", "Recipe", "User", "User" };
            Actions = new List<string> { "Index", "Index", "Index", "Create", "Index", "Login" };
            Texts = new List<string> { "Home", "Categories", "Search", "Create recipe", "My page", "Login" };

            Authenticated = new List<bool> { true, true, true, true, true, false };
            NotAuthenticated = new List<bool> { true, true, true, false, false, true };
        }

        public bool IsCurrent(string controller, string action)
        {
            object c = viewContext.RouteData.Values["controller"];
            object a = viewContext.RouteData.Values["action"];
            return String.Equals(controller, (string)c, StringComparison.InvariantCultureIgnoreCase) &&
                String.Equals(action, (string)a, StringComparison.InvariantCultureIgnoreCase);
        }
    }
}